/**
 * Urban Parks
 *
 * Team M&M's:
 * Michael Satran Jr
 * Michael Pogson
 * Stephen Hunter
 *
 * Date: Mar 5, 2012
 */
package tests;

import static org.junit.Assert.*;

import model.Date;

import org.junit.Before;
import org.junit.Test;

/**
 * @author Michael Pogson
 *
 */
public class DateTest {
	
	/**
	 * Object used for testing
	 */
	Date my_date;
	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		
	my_date = new Date(5,31,2012);
		
	}

	/**
	 * Test method for constructor that takes a string.
	 */
	@Test
	public void testDateString() {
		
		Date date = new Date("5/31/1984");
		
		assertEquals("month is not the same", 5, date.getMonth());
		assertEquals("Day is not the same", 31, date.getDay());
		assertEquals("Year is not the saem", 1984, date.getYear());
		
	}

	/**
	 * Test method to see if a date comes before another date.
	 */
	@Test
	public void testComesBefore() {
		Date date = new Date("5/31/1984");
		
		
		assertTrue("did not come before", date.comesBefore(my_date));
	}

	/**
	 * Test method to see if the date moves a given amount of days ahead.
	 */
	@Test
	public void testNDaysLater() {
		
		Date newdate = my_date.nDaysLater(2);
		
		assertEquals("date did not move ahead", 2, newdate.getDay());
	}

	/**
	 * Test method to see if the date moves some number of days ahead.
	 */
	@Test
	public void testNDaysEarlier() {
		
		Date newdate = my_date.nDaysEarlier(2);
		
		assertEquals("date did not move ahead", 29, newdate.getDay());
	}

	/**
	 * Test method to see if the proper amount of days in amonth is returned.
	 */
	@Test
	public void testDaysInMonth() {
		
		assertEquals("Didnt equal 31",31, Date.daysInMonth(5, 2012));
		assertEquals("Didnt think it was a leap year",29, Date.daysInMonth(2, 2012));
		assertEquals("it wasnt a leap year",28, Date.daysInMonth(2, 2011));
	}

	/**
	 * Test method to see if the proper amount of days between dates is returned.
	 */
	@Test
	public void testDaysBetween() {
		
		Date newdate = new Date("6/2/2012");
		
		assertEquals("didnt equal 1", 1, my_date.daysBetween(newdate));
	}

	/**
	 * Test method to see if the month name is returned properly.
	 */
	@Test
	public void testGetMonthName() {
		
		assertEquals("Didnt return properly", "May", Date.getMonthName(5));
	}

	/**
	 * Test method to see if the proper day of week is returned.
	 */
	@Test
	public void testGetDayOfWeek() {
		
		assertEquals("didnt return the proper day of week.", 4, my_date.getDayOfWeek());
	}

	/**
	 * Test method to see if the two dates are equal.
	 */
	@Test
	public void testEqualsObject() {
		Date newdate = new Date("5/31/2012");
		
		
		assertTrue("these dates didnt equal", my_date.equals(newdate));
	}

}
